#!/bin/bash


# ls
# artisan composer.json database.php package.json server.php app
#

php artisan command:queue_redis_group_consumer_msg_server --env=wx792152cf7d4b3d45 --group_name=visit_log_ceshi


# ps -aux
# USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
# root       151  0.0  0.0   2392   760 pts/1    S    14:43   0:00 sh ./sh/queue_redis_group_consumer_msg_server.sh wx792152cf7d4b3d45 visit_log_ceshi
# root       152  4.0  1.9 106568 40372 pts/1    S    14:43   0:00 php artisan command:queue_redis_group_consumer_msg_server --env=wx792152cf7d4b3d45 --group_name=visit_log_ceshi
#
# ps -aux | grep wx792152cf7d4b3d45
# root       151  0.0  0.0   2392   760 pts/1    S    14:43   0:00 sh ./sh/queue_redis_group_consumer_msg_server.sh wx792152cf7d4b3d45 visit_log_ceshi
# root       152  1.2  1.9 108616 40372 pts/1    S    14:43   0:00 php artisan command:queue_redis_group_consumer_msg_server --env=wx792152cf7d4b3d45 --group_name=visit_log_ceshi
# root       158  0.0  0.0   3088   820 pts/1    S+   14:43   0:00 grep wx792152cf7d4b3d45
#
# ps -aux | grep wx792152cf7d4b3d45 | grep visit_log_ceshi
# root       151  0.0  0.0   2392   760 pts/1    S    14:43   0:00 sh ./sh/queue_redis_group_consumer_msg_server.sh wx792152cf7d4b3d45 visit_log_ceshi
# root       152  0.9  2.0 108616 40684 pts/1    S    14:43   0:00 php artisan command:queue_redis_group_consumer_msg_server --env=wx792152cf7d4b3d45 --group_name=visit_log_ceshi
#
# "cut -c 9-15" 是截取输入行的第9个字符到第15个字符，而这正好是进程号PID
# ps -aux | grep wx792152cf7d4b3d45 | grep visit_log_ceshi | cut -c 9-15
#    151
#    152
#
# ps -aux | grep wx792152cf7d4b3d45 | grep visit_log_ceshi | awk '{print $2}'
# 151
# 152
#
#
# linux下批量杀死进程（使用了xargs）
# 杀掉所有nsq相关进程
# ps -ef | grep nsq | grep -v grep | awk '{print $2}' | xargs kill
# https://blog.csdn.net/zhangyuan12805/article/details/79709134
#
# ps -aux | grep wx792152cf7d4b3d45 | grep visit_log_ceshi | awk '{print $2}' | xargs kill -9
# [1]+  Killed                  sh ./sh/queue_redis_group_consumer_msg_server.sh wx792152cf7d4b3d45 visit_log_ceshi >> wx792152cf7d4b3d45_visit_log_ceshi.txt
#
#
#
# kill: failed to parse argument: 'PID'
# kill: (214): No such process
#
#
#
#
# 关于xargs的用法可参见：
# https://www.cnblogs.com/wangqiguo/p/6464234.html
# 管道和xargs的区别
# 管道是作为后面的命令的输入的，而xargs是作为后面命令的参数
# awk是什么的缩写？看这里：
# https://kb.iu.edu/d/abnd
#


